using System;
using System.Collections.Generic;
using System.Linq;
using RMH.Entities;
using RMH.Services;

namespace RMH.Web.FakeServices
{
    public class FakeSupportPersonService : ISupportPersonService
    {
        private static List<SupportPerson> _supportPersons = new List<SupportPerson>
                                                                    {
                                                                        new SupportPerson(){Id = 1, LastName = "Smith", FirstName = "Jack", 
                                                                                            PhoneNumber = "(517) 555-1234", Address = new Address(){Street1 = "1 Main St", City = "Lansing", State = "MI", PostalCode = "12345"},
                                                                                           },
                                                                        new SupportPerson(){Id = 2, LastName = "Johnson", FirstName = "Sam",
                                                                                            PhoneNumber = "(517) 654-1234", Address = new Address(){Street1 = "1 Oak St", City = "Detroit", State = "MI", PostalCode = "12346"},
                                                                                           },
                                                                        new SupportPerson(){Id = 3, LastName = "Anderson", FirstName = "Bob",
                                                                                            PhoneNumber = "(517) 123-1234", Address = new Address(){Street1 = "1 Maple St", City = "Bay City", State = "MI", PostalCode = "24687"},
                                                                                           },
                                                                        new SupportPerson(){Id = 4, LastName = "Bailey", FirstName = "Kip",
                                                                                            PhoneNumber = "(517) 765-1234", Address = new Address(){Street1 = "1 Birch St", City = "Traverse City", State = "MI", PostalCode = "62486"},
                                                                                           },
                                                                        new SupportPerson(){Id = 5, LastName = "Doe", FirstName = "Frank",
                                                                                            PhoneNumber = "(517) 343-1234", Address = new Address(){Street1 = "1 Elm St", City = "Kalamazoo", State = "MI", PostalCode = "66823"},
                                                                                           },
                                                                        new SupportPerson(){Id = 6, LastName = "Harvey", FirstName = "Ralph",
                                                                                            PhoneNumber = "(517) 876-1234", Address = new Address(){Street1 = "1 Main St", City = "Flint", State = "MI", PostalCode = "98765"},
                                                                                           },
                                                                        new SupportPerson(){Id = 7, LastName = "Washington", FirstName = "Jen",
                                                                                            PhoneNumber = "(517) 555-1234", Address = new Address(){Street1 = "1 Market St", City = "Ann Arbor", State = "MI", PostalCode = "34523"},
                                                                                           },
                                                                        new SupportPerson(){Id = 8, LastName = "Adams", FirstName = "Kate",
                                                                                            PhoneNumber = "(517) 888-1234", Address = new Address(){Street1 = "1 Main St", City = "Lansing", State = "MI", PostalCode = "54321"},
                                                                                           }
                                                                    };

        public IList<SupportPerson> GetAll()
        {
            return _supportPersons;
        }

        public IList<SupportPerson> Search(string firstName, string lastName)
        {
            return _supportPersons.Where(p => (String.IsNullOrEmpty(firstName) || p.FirstName == firstName) && (String.IsNullOrEmpty(lastName) || p.LastName == lastName)).ToList();
        }

        public SupportPerson Get(int id)
        {
            return _supportPersons.Where(p => p.Id == id).FirstOrDefault();
        }

        public void Save(SupportPerson item)
        {
            throw new NotImplementedException();
        }
    }
}